﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BO
{
    partial class PrincipalGame
    {
        
        public string PK { get { return "PK"; } }
        
        public string AreaA { get; set; }
        
        public string AreaB { get; set; }

        
        public double AmountA { get; set; }
        
        public double AmountB { get; set; }

        
        public double ReachedAmountA { get; set; }
        
        public double ReachedAmountB { get; set; }

        
        public string RateA { get; set; }
        
        public string RateB { get; set; }


        public void LoadData(DateTargetsList targets)
        {

            //Load A
            var ta = (from item in targets
                      where item.Principal == this.PrincipalA
                      select item).FirstOrDefault();
            if (ta != null)
            {
                this.AreaA = string.Format("{0} {1} {2}", ta.CompanyName, ta.CenterName, ta.DepartmentName);
                this.AmountA = ta.Amount;
                this.ReachedAmountA = ta.ReachedAmount;
                this.RateA = ta.Rate;
            }

            //Load B
            ta = (from item in targets
                  where item.Principal == this.PrincipalB
                  select item).FirstOrDefault();
            if (ta != null)
            {
                this.AreaB = string.Format("{0} {1} {2}", ta.CompanyName, ta.CenterName, ta.DepartmentName);
                this.AmountB = ta.Amount;
                this.ReachedAmountB = ta.ReachedAmount;
                this.RateB = ta.Rate;
            }

        }
    }
}
